package day0326;

import java.util.Arrays;
import java.util.Scanner;

//有若干只鸡和兔子放在一个笼子里，
//共有35个头，共有94只脚。
//问笼中各有多少只鸡和兔？
public class Test8 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入头的数量：");
        int hc = sc.nextInt();
        System.out.println("请输入脚的数量：");
        int fc = sc.nextInt();
        String[] r=Test8.animalCount(hc, fc);
        System.out.println(Arrays.toString(r));
    }
    //                                     48             94
    public static String[] animalCount(int headCount, int footCount) {
        String[]  result={};
        for (int ji = 1; ji <= Math.min(footCount/2,  headCount) ; ji++) {//   47
            for (int tu = 1; tu < Math.min(footCount/4,  headCount) ; tu++) {//tu 1 2 3 4 5
                if( (tu*4 + ji*2 ==footCount)&&(tu+ji==headCount) ){
                    result=Arrays.copyOf(result,result.length+1);
                    result[result.length-1]=   ji +","+tu  ;
                }
            }
        }
        return result;
    }
}



